var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/qijie', {useNewUrlParser: true});
mongoose.set('useFindAndModify', false);

var articleSchema = new mongoose.Schema({
  title: String,
  content: String,
  nextUrl: String,
  number: Number
})
var Article = mongoose.model('arcile', articleSchema);

async function QueryAll(){
  const result = await Article.find().exec()
  return result
}

async function  QueryAllByNum (number){
  const result = await Article.findOne({number: number}).exec()
  return result
}
// QueryAllByNum(1) 
// process.exit(1);

module.exports = {
  QueryAll,
  QueryAllByNum
}
